//
//  ROMainTabBarViewController.swift
//  健身宝
//
//  Created by hzt on 2017/9/26.
//  Copyright © 2017年 hzt. All rights reserved.
//

import UIKit

class ROMainTabBarViewController: RDVTabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupTabBarController()
    }
    
    func setupTabBarController()
    {
        
        let homePageStoryboard : UIStoryboard = UIStoryboard(name: "homePage", bundle: nil)
        let homePageNaigationController : UIViewController = homePageStoryboard.instantiateViewController(withIdentifier: "homePageNav")
        
        let collectionStoryboard : UIStoryboard = UIStoryboard(name: "collection", bundle: nil)
        let collectionNaigationController : UIViewController = collectionStoryboard.instantiateViewController(withIdentifier: "collectionNav")
        
        let meStoryboard : UIStoryboard = UIStoryboard(name: "me", bundle: nil)
        let meNaigationController : UIViewController = meStoryboard.instantiateViewController(withIdentifier: "meNav")
        let searchStoryBoard: UIStoryboard = UIStoryboard(name: "Search", bundle: nil)
        
        let searchNavgationController: UIViewController = searchStoryBoard.instantiateViewController(withIdentifier: "SearchNav")
        
        self.viewControllers = [homePageNaigationController,collectionNaigationController,searchNavgationController,meNaigationController]
        
        let tabBarItemImages = ["first","second","fourth","third"]
        let tabBarItemTitles = ["店铺","收藏","搜索","我"]
        
        let tabBar = self.tabBar
        tabBar?.frame = CGRect(x: (tabBar?.frame.minX)!, y: (tabBar?.frame.minY)!, width: (tabBar?.frame.width)!, height: 63)
        var index : Int = 0
        
        for item  in self.tabBar.items as! [RDVTabBarItem]{
            
            let selectedimage = UIImage(named: "\(tabBarItemImages[index])"+"_select")
            let unselectedimage = UIImage(named: "\(tabBarItemImages[index])"+"_unselect")
            
            item.setFinishedSelectedImage(selectedimage, withFinishedUnselectedImage: unselectedimage)
            item.title = tabBarItemTitles[index]
            index += 1
        }
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    /*
     // MARK: - Navigation
     
     // In a storyboard-based application, you will often want to do a little preparation before navigation
     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
     // Get the new view controller using segue.destinationViewController.
     // Pass the selected object to the new view controller.
     }
     */
    
}

